<template>
    <!-- 用于购物车的加减框 -->
    <div class="mui-numbox" data-numbox-min='1'>
        <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
        <input class="mui-input-numbox" type="number" :value="buycount" ref="num" @change="numChange" />
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
</template>

<script>
    import mui from './../../lib/mui/js/mui.min.js'
    export default {
        data() {
            return {

            }
        },
        methods: {
            numChange() {
                // 当数据发生改变的时候，把数据同步到vuex    
                //console.info('id:' + this.id);             
                this.$store.commit('update', {
                    id: this.id,
                    count:  parseInt(this.$refs.num.value)
                })
            }
        },
        mounted() {

            mui('.mui-numbox').numbox();

            console.info(this.buycount);

        },
        //商品id,购买数量
        props: ['buycount', 'id']
    }
</script>